import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class CanvasEditor implements ActionListener, MouseListener{
	private JButton currentButton;
	public CanvasEditor(JButton initialButton){
		this.currentButton = initialButton;
	}
	public void actionPerformed(ActionEvent ae){
		currentButton = (JButton) ae.getSource();
	}
	public void mouseClicked(MouseEvent e){
		int x = e.getX();
		int y = e.getY();
		JPanel canvas = (JPanel) e.getSource();
		if(currentButton.getText().equals("Ellipse"))
			canvas.getGraphics().drawOval(x-30,y-20,60,40);
		else if(currentButton.getText().equals("Rect"))
			canvas.getGraphics().drawRect(x-30,y-20,60,40);
		else
			canvas.getGraphics().drawRect(x-25,y-25,50,50);
	}
	public void mousePressed(MouseEvent e){}
	public void mouseReleased(MouseEvent e){}
	public void mouseEntered(MouseEvent e){}
	public void mouseExited(MouseEvent e){}
}
